#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=1e5+10;
int n,m,L,V;
int d[N],v[N],a[N];
int p[N];
struct node{
    int l,r;
}det[N];int cnt=0;
ll sqr_v(int x,int i){
    if(x<d[i])return 0;
    return 1ll*v[i]*v[i]+1ll*2*a[i]*(x-d[i]);
}
bool cmp(const node a,const node b){
    if(a.l==b.l)return a.r<b.r;
    return a.l<b.l;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    scanf("%d",&T);
    while(T--){
        cnt=0;
        scanf("%d%d%d%d",&n,&m,&L,&V);
        for(int i=1;i<=n;i++){
            scanf("%d%d%d",&d[i],&v[i],&a[i]);
        }
        for(int i=1;i<=m;i++){
            scanf("%d",&p[i]);
        }
        int ans1=0;
        for(int i=1;i<=n;i++){
            if(a[i]<0){//yun jian su
                int l=lower_bound(p+1,p+1+m,d[i])-p;
                if(l>m)continue;
                if(sqr_v(p[l],i)>1ll*V*V){
                    det[++cnt].l=l;
                    ans1++;
                    int r=m,res=l;
                    while(l<r){
                        int mid=l+r+1>>1;
                        if(sqr_v(p[mid],i)>1ll*V*V)l=mid;
                        else r=mid-1;
                    }
                det[cnt].r=r;
                }
            }else if(a[i]==0){//yun su
                if(v[i]>V){
                    int l=lower_bound(p+1,p+1+m,d[i])-p;
                    if(l>m)continue;
                    ans1++;
                    det[++cnt]={l,m};
                }
            }else{//yun jia su
                if(sqr_v(p[m],i)>1ll*V*V){
                    ans1++;
                    int l=lower_bound(p+1,p+1+m,d[i])-p,r=m;
                    if(l>m)continue;
                    while(l<r){
                        int mid=l+r>>1;
                        if(sqr_v(p[mid],i)>1ll*V*V)r=mid;
                        else l=mid+1;
                    }
                    det[++cnt]={r,m};
                }
            }
        }
        printf("%d ",ans1);
        sort(det+1,det+1+cnt,cmp);
        int ans2=0,la=0;
        for(int i=1;i<=cnt;i++){
            if(det[i].l>la){
                ans2++;
                la=det[i].r;
            }
            la=min(la,det[i].r);
        }
        printf("%d\n",m-ans2);
    }
    return 0;
}
